home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap12 / dun12_4.txt < prev    next >
Encoding:
Text File  |  1997-12-18  |  691 b   |  32 lines

  1. <HTML>
  2.  
  3. <HEAD>
  4.  
  5. <TITLE>scripting position - communicator</TITLE>
  6.  
  7. </HEAD>
  8.  
  9. <SCRIPT LANGUAGE="JavaScript">
  10.  
  11. function random (limit)
  12.  
  13.     {
  14.  
  15.      return (Math.round(((Math.random())*1000))%limit)+1;
  16.  
  17.     }
  18.  
  19. function moveElement()
  20.  
  21.     {
  22.  
  23.     document.layers['movingElement'].left=random(300);
  24.  
  25.     document.layers['movingElement'].top=random(300);
  26.  
  27.     }
  28.  
  29. </SCRIPT>
  30.  
  31. <STYLE TYPE="text/css">
  32.  
  33. .comeAlong{
  34.  
  35.     POSITION: absolute;
  36.  
  37.     TOP: 100px;
  38.  
  39.     LEFT: 100px;
  40.  
  41.     }
  42.  
  43. </STYLE>
  44.  
  45. <BODY BGCOLOR="#ffffff">
  46.  
  47.  
  48.  
  49. <DIV ID="movingElement" CLASS="comeAlong">
  50.  
  51. <FORM>
  52.  
  53. <INPUT TYPE=BUTTON VALUE="you move me" ONCLICK="moveElement()">
  54.  
  55. </FORM>
  56.  
  57. </DIV>
  58.  
  59. </BODY>
  60.  
  61. </HTML>
  62.  
  63.